package spring.cloud.service.task.analyzer;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class DashboardServiceHelper {


    public static List<TaskStatistics> sortJobByLoadLevel(List<TaskStatistics> taskStatisticsList) {
        Collections.sort(taskStatisticsList, new Comparator<TaskStatistics>() {
            @Override
            public int compare(TaskStatistics o1, TaskStatistics o2) {
                return o1.getTotalLoadLevel() < o2.getTotalLoadLevel() ? 1//max排前面
                        : (o1.getTotalLoadLevel() == o2.getTotalLoadLevel() ? 0 : -1);
            }
        });
        return taskStatisticsList;
    }


    public static List<ExecutorStatistics> sortExecutorByLoadLevel(List<ExecutorStatistics> executorStatisticsList) {
        Collections.sort(executorStatisticsList, new Comparator<ExecutorStatistics>() {
            @Override
            public int compare(ExecutorStatistics o1, ExecutorStatistics o2) {
                return o1.getLoadLevel() < o2.getLoadLevel() ? 1 ://max排前面
                        (o1.getLoadLevel() == o2.getLoadLevel() ? 0 : -1);
            }
        });
        return executorStatisticsList;
    }


}
